
package interrupt;

public class Memory {
    private final short[] memory;
    public Memory(){
        this.memory = new short[32768];
    }
    
    public void setMemory(short address, short data) {
        this.memory[address] = data ;
    }
    
    public short getMemory(short address) {
        return this.memory[address];
    }
    
    public byte getOPE(short address){
        return (byte) (this.memory[address] >>> 8 & 0x000000ff );
    }
    
    public byte getDR(short address) {
        return (byte) (this.memory[address] >>> 4 & 0x0000000f );
    }
    
    public byte getSR(short address) {
        return (byte) (this.memory[address] & 0x0000000f);
    }
    
    public byte getOffset(short address){
        return (byte) (this.memory[address] & 0x000000ff);
    }
}
